package com.itfreer.gis.data.fileanalyze;

import com.itfreer.gis.data.file.GpsFileDataEditServer;
import com.itfreer.utils.json.JsonUtils;
import org.opengis.feature.simple.SimpleFeature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * shape文件解析服务
 */
@Component("txtFileAnalysis")
public class TxtFileAnalysisServiceImp  {

	@Autowired(required = false)
	private GpsFileDataEditServer gpsFileAnalysis;

	public String analyseFile(Map<String, String[]> param, String filePath, String uid, String un) {
		try {
			List<SimpleFeature> graphic = gpsFileAnalysis.queryFeature(filePath, null);
			HashMap<String, Object> result = new HashMap<String, Object>();
			result.put("status", true);
			result.put("graphic", AnalyseUtil.getGemetry(graphic));
			return JsonUtils.toJSONString(result);
		} catch (Exception e) {
			e.printStackTrace();
			return "{\"status\":false}";
		}
	}
}
